//
//  MSInviteListTVC.m
//  MSMain
//
//  Created by Dgh Hv on 2018/9/19.
//  Copyright © 2018年 土豆. All rights reserved.
//

#import "MSInviteListTVC.h"
#import "MSRewardOrInviteListModel.h"

@interface MSInviteListTVC()
@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UIView *goddessView;
@property (weak, nonatomic) IBOutlet UILabel *inviteTime;
@property (weak, nonatomic) IBOutlet UILabel *certificateStatus;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameWidth;
@property (weak, nonatomic) IBOutlet UILabel *tagLabel;

@end

@implementation MSInviteListTVC

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    ViewRadius(self.headImage, 3);
    self.headImage.contentMode = UIViewContentModeScaleAspectFill;
    ViewRadius(self.goddessView, 7);
    // Initialization code
}

-(void)getInfoFromModel:(MSRewardOrInviteListModel *)model
{
    [self.headImage sd_setImageWithURL:URLTOSTRING(model.HeadImg)];
    self.name.text = model.UserName;
    self.inviteTime.text = NSStringFormat(@"邀请时间 %@",model.CreateTime);
    self.goddessView.hidden = YES;
    switch ([model.Status integerValue]) {
        case -1: //审核中
        {
            self.certificateStatus.textColor = RGB_HEX(0xFFBB01);
            self.certificateStatus.text = @"审核中";
        }
            break;
        case 0: //未认证
        {
            self.certificateStatus.textColor = RGB_HEX(0xFF3A30);
            self.certificateStatus.text = @"未认证";
        }
            break;
        case 1: //主播
        {
            self.certificateStatus.textColor = RGB_HEX(0x42C570);
            self.certificateStatus.text = @"已认证";
            self.goddessView.hidden = NO;
            if([model.Sex isEqualToString:@"1"])
            {
                self.goddessView.backgroundColor = RGB_HEX(0xFF4C88);
                self.tagLabel.text = @"女神";
            }else
            {
                self.goddessView.backgroundColor = RGB_HEX(0x45B8F9);
                self.tagLabel.text = @"男神";
            }
        }
            break;
            
        default:
            self.certificateStatus.textColor = RGB_HEX(0xFF3A30);
            self.certificateStatus.text = @"未认证";
            break;
    }
    
    float width = [kUtilityClass widthForString:model.UserName fontSize:18];
    if(width > KScreenWidth - 180)
    {
        self.nameWidth.constant = KScreenWidth - 180 - 38;
    }else
    {
        self.nameWidth.constant = width;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
